";
Result=mysql_db_query ("Guanggao", query);
Numrows=mysql_num_rows (result);
Use the Mysql_fetch_object () function to obtain useful column information and coexist in the corresponding array;
while (row = mysql_fetch_object (result)) {
adurl[]= row->url;
adbanner[]= row->banner;
adalt[]= row->alt;
adpriority[]= row->priority;
}
initialization of intermediate variables;
Numcheck= NumRows;
I= pricount=0;
The maximum random number is obtained.
while (N
array. add the weights of all ads to get the maximum random number. each time you load the page, use srand () generate a random tree seed, use the rand () function to generate a random number from 1 to the maximum random number, and then randomly display different advertising lines according to certain rules, the larger the weight, the larger the chance to be displayed.
# ShowAd. php3 -- randomly display advertisements #
// Select a database for connection;
Connection = mysql_connect ();
Mysql
#// Select a database for connection;Connection = mysql_connect ();Mysql_select_db ("guanggao", connection );// Execute the query to obtain the number of ads;Query = "select URL, banner, ALT, priority from ad where priority> 0 ";Result = mysql_db_query ("guanggao", query );Numrows = mysql_num_rows (result );// Use the mysql_fetch_object () function to obtain useful column information and store it in the corresponding array;While (ROW = mysql_fetch_object (result )){Adurl [] = row-> URL;Adbanner
generate a random number from 1 to the maximum random number, and then randomly display different advertising lines according to certain rules, the larger the weight, the larger the chance to be displayed.
# ShowAd. php3 -- randomly display advertisements #
// Select a database for connection;
Connection = mysql_connect ();
Mysql_select_db ("guanggao", connection );
// Execute the query to obtain the number of ads;
Query = "SELECT url, banner, alt, priority FROM ad where priority> 0 ";
Result
displayed.
# ShowAd. php3 -- randomly display advertisements #
// Select a database for connection;
Connection = mysql_connect ();
Mysql_select_db ("guanggao", connection );
// Execute the query to obtain the number of ads;
Query = "SELECT url, banner, alt, priority FROM ad where priority> 0 ";
Result = mysql_db_query ("guanggao", query );
Numrows = mysql_num_rows (result );
// Use the mysql_fetch_object () function to obtain useful column information and store it in the corresponding array;
W
number of ads;
query= "Select URL, banner, ALT, priority from AD where priority > 0";
Result=mysql_db_query ("Guanggao", query);
Numrows=mysql_num_rows (result);
Use the Mysql_fetch_object () function to obtain useful column information and coexist in the corresponding array;
while (row = mysql_fetch_object (result)) {
adurl[]= row->url;
adbanner[]= row->banner;
adalt[]= row->alt;
adpriority[]= row->priority;
}
initialization of intermediate variable
", query);Numrows=mysql_num_rows (result);Use the Mysql_fetch_object () function to obtain useful column information and coexist in the corresponding array;while (row = mysql_fetch_object (result)) {adurl[]= row->url;adbanner[]= row->banner;adalt[]= row->alt;adpriority[]= row->priority;}initialization of intermediate variables;Numcheck= NumRows;I= pricount=0;The maximum random number is obtained.while (Numcheck) {pricount+= adpriority[i];i++; numcheck
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.